package com.seisys.util;


import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.seisys.entity.system.User;
import com.seisys.service.system.LogService;


public class LogUtil
{
    public final static String ADD = "增加";

    public final static String UPDATE = "更新";

    public final static String DELETE = "删除";

    public final static String QUERY = "查询";

    // 登录日志类型
    public final static String LOGIN = "LOGIN";

    public final static String LOGOUT = "LOGOUT";

    public static LogUtil getInstance()
    {
        return new LogUtil();
    }

    /**
     * @param type
     *            操作类型
     * @param moduleName
     *            模块名称
     * @param objId
     *            被操作对象ID，例如:删除一个user,此ID即位该user在数据库中记录的主键ID
     * @param logService
     *            日志服务
     * @param request
     *            当前请求
     * @throws Exception
     *             liuwei 下午1:33:54
     */
    public void operationLogger(String type, String moduleName, String objId,
                                LogService logService, HttpServletRequest request)
        throws Exception
    {
        HttpSession session = request.getSession();
        Map<String, Object> param = new HashMap<String, Object>();
        User user = (User)session.getAttribute("sessionUser");
        String user_id = user.getUSER_ID();
        param.put("id", UuidUtil.get32UUID());
        param.put("operaname", type);
        param.put("moduleName", moduleName);
        param.put("OBJ_ID", objId);
        param.put("user_id", user_id);
//        logService.save(param);//日志记录功能去掉
    }
}
